package com.dfrz.stockMarket.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dfrz.stockMarket.bean.MessageBean;
import com.dfrz.stockMarket.bean.UserBean;
import com.dfrz.stockMarket.cons.Constants;
import com.dfrz.stockMarket.model.UserStocksModel;
import com.dfrz.stockMarket.service.UserService;

public class CollectPageCtrl  extends BaseController{
	@Override 
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		String name=req.getParameter("name");
		String path = req.getContextPath();

		
		UserBean userBean = getSessionUserBean(req);
		UserService server =new UserService();
		
		UserBean ub=new UserBean();
		try {
			MessageBean massa=	server.getUserBeanByName(userBean.getUserInfoModel().getUserName());
			System.out.println("--------"+massa.getMsg());
			ub=(UserBean) massa.getMsg();
			System.out.println("ub---"+ub);
			List<UserStocksModel> userStocksModels = ub.getUserStocksModels();
			
			System.out.println("CollectPageCtrl-userStocksModels"+userStocksModels);
			setSession(req, "list", userStocksModels);
			
			req.setAttribute("path", path);
			req.setAttribute("uname", name);
			req.getRequestDispatcher("/WEB-INF/page/collect.jsp").forward(req, resp);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
		

	}
}
